package socketmvc.core.processor.bean;


import java.lang.reflect.InvocationTargetException;

/**
 * Created by xueyanjun on 2018/1/15.
 * 存储请求类相关信息
 */
public class Processor<T> {

    /* 对应根命令码 */
    private String command;

    private String name;
    /*class*/
    private Class<T> clazz;
    /*instance*/
    private T instance;

    public Processor(String name, Class<T> clazz, T instance) {
        this.name = name;
        this.clazz = clazz;
        this.instance = instance;
    }

    public Processor(Class<T> clazz, T instance) {
        this(clazz.getName(),clazz,instance);
    }

    public Processor(Class<T> clazz) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        this(clazz.getName(),clazz,clazz.getDeclaredConstructor().newInstance());
    }

    public String getCommand() {
        return command;
    }

    public void setCommand(String command) {
        this.command = command;
    }

    public Class<T> getClazz() {
        return clazz;
    }

    public void setClazz(Class<T> clazz) {
        this.clazz = clazz;
    }

    public T getInstance() {
        return instance;
    }

    public void setInstance(T instance) {
        this.instance = instance;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
